import QtQuick 2.12
import QtQuick.Layouts 1.12
import "../components"
Rectangle {

    id: root
    property string code: ""
    property string title: "DEFAULT_TITLE"
    property string isDefault: "0"
    property bool isOperable: true
    color: "#EBEDF0"


    height: 50*dp
    width: parent.width

    Rectangle{
        x: 1
        width: root.width / 2 - 2
        height: 49*dp
        color: "white"
        TextInput{
            id: textInput
            text: title
            anchors.fill: parent
            font.pixelSize: config.fontsize
            horizontalAlignment: Text.AlignHCenter
            verticalAlignment: Text.AlignVCenter
            onTextChanged: {
                updateItem(code, text)
            }
        }
    }
    Rectangle{
        x: root.width / 2
        width: parent.width / 2 - 1
        height: 49*dp
        RowLayout{
            y:5*dp
            height: 40*dp
            width: parent.width
            CustomHorSpacerItem{}
            PushButton{
                title: "添加"
                width: 60*dp
                text_color: "#1677FF"
                visible: isOperable
                onReleased: {
                    settingsDefault.addItem()
                }
            }PushButton{
                title: isDefault==="1" ? "[默认]" : "默认"
                width: 60*dp
                text_color: isDefault==="1" ? "#AAAAAA" : "#1677FF"
                onReleased: {
                    settingsDefault.setDefault(code)
                }
            }PushButton{
                title: "删除"
                width: 60*dp
                text_color: "#1677FF"
                visible: isOperable
                onReleased: {
                    settingsDefault.delItem(code)
                }
            }
            CustomHorSpacerItem{}
        }
    }

}
